﻿using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace SceneUnpacker.Schematrix
{
    public partial class TextInputDialog : Form
    {
        private Button CanxButton;
        private Container components;
        private string defaultValue = string.Empty;
        private TextBox InputValue;
        private Button OKButton;
        private Button ResetButton;

        public TextInputDialog()
        {
            this.InitializeComponent();
        }

        private void ResetButton_Click(object sender, EventArgs e)
        {
            this.InputValue.Text = this.defaultValue;
        }

        public void SelectAll()
        {
            this.InputValue.SelectAll();
        }

        private void TextInputDialog_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                base.DialogResult = DialogResult.Cancel;
            }
        }

        public char PasswordChar
        {
            get
            {
                return this.InputValue.PasswordChar;
            }
            set
            {
                this.InputValue.PasswordChar = value;
            }
        }

        public string Prompt
        {
            get
            {
                return this.Text;
            }
            set
            {
                this.Text = value;
            }
        }

        public string Value
        {
            get
            {
                return this.InputValue.Text;
            }
            set
            {
                if (value != this.InputValue.Text)
                {
                    this.InputValue.Text = value;
                    this.InputValue.SelectionStart = value.Length;
                    this.InputValue.SelectionLength = 0;
                    this.defaultValue = value;
                }
            }
        }
    }
}

